package org.xiyu.yee.onekeyminer_chainable_visual.client;

import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.KeyMapping;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
import org.lwjgl.glfw.GLFW;
import org.xiyu.yee.onekeyminer_chainable_visual.Onekeyminer_chainable_visual;

@EventBusSubscriber(modid = Onekeyminer_chainable_visual.MODID, bus = EventBusSubscriber.Bus.MOD)
public class KeyBindings {
    
    public static final String KEY_CATEGORY = "key.category." + Onekeyminer_chainable_visual.MODID;
    
    // 按键：显示交互高亮（默认Shift）
    public static final KeyMapping SHOW_INTERACTION_KEY = new KeyMapping(
            "key." + Onekeyminer_chainable_visual.MODID + ".show_interaction",
            InputConstants.Type.KEYSYM,
            GLFW.GLFW_KEY_LEFT_SHIFT,
            KEY_CATEGORY
    );
    
    // 按键：打开配置屏幕（默认O）
    public static final KeyMapping OPEN_CONFIG_KEY = new KeyMapping(
            "key." + Onekeyminer_chainable_visual.MODID + ".open_config",
            InputConstants.Type.KEYSYM,
            GLFW.GLFW_KEY_O,
            KEY_CATEGORY
    );
    
    @SubscribeEvent
    public static void registerKeyMappings(RegisterKeyMappingsEvent event) {
        event.register(SHOW_INTERACTION_KEY);
        event.register(OPEN_CONFIG_KEY);
    }
    
    /**
     * 检查是否按住了显示交互高亮的按键
     * @return true if the key is currently pressed
     */
    public static boolean isShowInteractionKeyPressed() {
        return SHOW_INTERACTION_KEY.isDown();
    }
    
    /**
     * 检查是否按下了打开配置屏幕的按键
     * @return true if the key was just pressed
     */
    public static boolean wasOpenConfigKeyPressed() {
        return OPEN_CONFIG_KEY.consumeClick();
    }
}